<form action="{% url 'polls:vote' question.id %}" method="post" class="vote-form">
    {% csrf_token %}

    <div class="form-container">
        <!-- 标题区域 -->
        <h1 class="question-title">{{ question.question_text }}</h1>

        <!-- 错误提示增强 -->
        {% if error_message %}
        <div class="error-alert" role="alert">
            ⚠️ {{ error_message }}
        </div>
        {% endif %}

        <!-- 选项容器 -->
        <div class="choices-container">
            {% for choice in question.choice_set.all %}
            <div class="choice-item">
                <input type="radio"
                       name="choice"
                       id="choice{{ forloop.counter }}"
                       value="{{ choice.id }}"
                       class="choice-input">
                <label for="choice{{ forloop.counter }}" class="choice-label">
                    <span class="radio-indicator"></span>
                    {{ choice.choice_text }}
                </label>
            </div>
            {% empty %}
            <p class="no-choices">暂无可用选项</p>
            {% endfor %}
        </div>

        <!-- 提交按钮 -->
        <button type="submit" class="submit-btn">
            🗳️ Vote，点击投票
        </button>

        <!-- 新增返回首页按钮 -->
        <a href="{% url 'polls:index' %}" class="back-btn">
            ↩️ 返回投票首页
        </a>

    </div>
</form>

<style>
/* 现代极简风格样式 */
.vote-form {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.question-title {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.choices-container {
    margin: 1rem 0;
}

.choice-item {
    margin: 0.8rem 0;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.choice-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.choice-input {
    opacity: 0;
    position: absolute;
}

.choice-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: #34495e;
}

.radio-indicator {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    border: 2px solid #bdc3c7;
    border-radius: 50%;
    margin-right: 1rem;
    position: relative;
    transition: border-color 0.3s ease;
}

.choice-input:checked + .choice-label .radio-indicator {
    border-color: #3498db;
    background: #3498db;
}

.choice-input:checked + .choice-label .radio-indicator::after {
    content: "";
    position: absolute;
    width: 0.6em;
    height: 0.6em;
    background: white;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.error-alert {
    color: #c0392b;
    background: #fadbd8;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 统一按钮基础样式 */
.submit-btn,
.back-btn {
    box-sizing: border-box;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    text-align: center;
}

/* 提交按钮专属样式 */
.submit-btn {
    background: #3498db;
    color: white;
}

.submit-btn:hover {
    background: #2980b9;
}

/* 返回按钮专属样式 */
.back-btn {
    display: block;
    background: #95a5a6;
    color: white;
    text-decoration: none;
}

.back-btn:hover {
    background: #7f8c8d;
}

.no-choices {
    color: #7f8c8d;
    text-align: center;
    padding: 1rem;
}
</style>